package core;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Properties;

import edu.stanford.nlp.ling.CoreAnnotations.DocDateAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.NamedEntityTagAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.Annotator;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.time.SUTime;
import edu.stanford.nlp.time.TimeAnnotations;
import edu.stanford.nlp.time.TimeAnnotations.TimexAnnotation;
import edu.stanford.nlp.time.TimeAnnotations.TimexAnnotations;
import edu.stanford.nlp.time.TimeAnnotator;
import edu.stanford.nlp.time.Timex;
import edu.stanford.nlp.util.CoreMap;

public class TimexTaggerWrapper {
	public static void main(String[] args)
	{
		
		Properties props = new Properties();
		props.put("annotators", "tokenize, ssplit, pos, lemma, ner");
		StanfordCoreNLP snlp = new StanfordCoreNLP(props);
		
		String text = "Her wounds healed well without incident and the needle jejunostomy tube was utilized on the first postoperative day right up until the time of discharge , infusing Vivonex T.E.N";
		
		Annotation document = new Annotation(text);
		snlp.annotate(document);
//		Properties prop = new Properties();
//		prop.setProperty("mytimex.rules", "sutime/english.sutime.txt");
		TimeAnnotator timexann = new TimeAnnotator();//"mytimex", prop);
		document.set(DocDateAnnotation.class, (new Date()).toString());
		timexann.annotate(document);
		
		
		 List<CoreMap> sentences = document.get(SentencesAnnotation.class);
    
		    for(CoreMap sentence: sentences) {
		    	
		      // traversing the words in the current sentence
		      // a CoreLabel is a CoreMap with additional token-specific methods
		    	List<CoreMap> timexCoreMap= (List<CoreMap>)sentence.get(TimexAnnotations.class);
		      for (CoreMap timexCorm: timexCoreMap) {
		    	  Timex timex = timexCorm.get(TimexAnnotation.class);
		        System.out.println(timex);
		      }
		
	}
}
}
